using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using FutureOpen.Core.func.index;

namespace FutureOpen.IndexService
{
    partial class IndexService : ServiceBase
    {
        public IndexService()
        {
            InitializeComponent();
            if (!System.Diagnostics.EventLog.SourceExists("IndexServiceLogSourse"))
                System.Diagnostics.EventLog.CreateEventSource("IndexServiceLogSourse", "IndexServiceLog");

            eventLog1.Source = "IndexServiceLogSourse";
            // the event log source by which 

            //the application is registered on the computer

            eventLog1.Log = "IndexServiceLog";

        }

        protected override void OnStart(string[] args)
        {
            // TODO: Add code here to start your service.
            eventLog1.WriteEntry("Index service started");
            while (true)
            {
                Indexer.index();
                Thread.Sleep(Indexer.time_interval);
            }
        }
        protected override void OnStop()
        {
            // TODO: Add code here to perform any tear-down necessary to stop your service.
            eventLog1.WriteEntry("Index service stoped");
        }
        protected override void OnContinue()
        {
            eventLog1.WriteEntry("Index service is continuing in working");
        }

    }
}
